package cn.ekuma.pos.pda.finder;

import java.util.ArrayList;
import java.util.List;
import android.app.ProgressDialog;
import android.view.View;
import cn.ekuma.data.ui.android.AbstractViewBeanListAdapter;
import cn.ekuma.data.ui.android.AbstractListChildFinderActivate;
import cn.ekuma.epos.datalogic.DataLogicPDA;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.pos.pda.finder.adapter.ProductLotStoreAdapter;

import com.openbravo.bean.Product;
import com.openbravo.bean.erp.viewbean.LotNoStockCurrentInfo;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.query.QBFCompareEnum;

public class ProductLotStoreFinderActivator extends AbstractListChildFinderActivate<LotNoStockCurrentInfo,Product>{

	public ProductLotStoreFinderActivator() {
		super(DataLogicPDA.getDataLogic());	
	}

	@Override
	public AbstractViewBeanListAdapter getListAdapter() {
		return new ProductLotStoreAdapter(this);
	}

	@Override
	public void filterParaReset() {

	}

	@Override
	public void initAdvSeachView() {
		// TODO Auto-generated method stub
	}

	@Override
	public boolean isQuickSeachAble() {
		return true;
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		onQuickSeach(null);
	}

	@Override
	public void onQuickSeach(String inputText) {
		final Object[] filter=new Object[] {
	    		QBFCompareEnum.COMP_EQUALS, parent.getID(),
	    		QBFCompareEnum.COMP_NONE, new Double(0)};
		
		final ProgressDialog dialog = ProgressDialog.show(this, "", 
		        "查旬中，请稍等 …", true, true);
		new Thread(){
			@Override
			public void run(){
				I_DataLogicERP dlERP=DataLogicPDA.getDLERP();
				try {
					List<LotNoStockCurrentInfo> lists=dlERP.listByFilterWithClassName(LotNoStockCurrentInfo.class.getName(),filter);
					if(lists==null)
						lists=new ArrayList<LotNoStockCurrentInfo>();
					mHandler.obtainMessage(MSG_SUCCESS,lists).sendToTarget();//获取图片失败   

				} catch (BasicException e) {
					mHandler.obtainMessage(MSG_FAILURE).sendToTarget();//获取图片失败   
				}
				dialog.dismiss(); 
			}
			}.start();
		
	}

	@Override
	public View createFilterPanel() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public View createAdvFilterPanel() {
		// TODO Auto-generated method stub
		return null;
	}
/**
	Object[] filter=new Object[] {
    		QBFCompareEnum.COMP_EQUALS, baseBeanID,
    		unitCompare, new Double(0)};
   };
   
   .listByFilter(LotNoStockCurrentInfo.class,createValue()
	*/

	@Override
	public Class getFindClass() {
		return LotNoStockCurrentInfo.class;
	}

	@Override
	public Class getParentClass() {
		return Product.class;
	}
	
	
	
}
